package com.it.stone_manage.controller;

import com.it.stone_manage.model.SearchData;
import com.it.stone_manage.model.StoneRecord;
import com.it.stone_manage.service.RecordService;
import com.it.stone_manage.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.util.Map;

@RestController
//解决跨域问题
@CrossOrigin
public class RecordController {
@Autowired
    RecordService recordService;

@PostMapping("searchRecordData")
    public Map<String ,Object> searchRecordData(@RequestBody SearchData searchData){
    return recordService.searchRecordData(searchData);
}
@PostMapping("saveRecordData")
    public Result saveRecordData(@RequestBody StoneRecord stoneRecord){
    return  recordService.saveRecordData(stoneRecord);
}
@PostMapping("deleteRecordData")
    public Result deleteRecordData(@RequestBody StoneRecord stoneRecord){
    return  recordService.deleteRecordData(stoneRecord);
}
@PostMapping("upload")
    public Result upload(@RequestParam("username") String userName,@RequestParam("excelFile")MultipartFile uploadFile){
    return recordService.upload(uploadFile);
}
@PostMapping("downloadTemplate")
    public void downloadTemplate(HttpServletResponse response){
    recordService.downloadTemplate(response);
}
}
